package supershop4.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import supershop4.dao.IProductDao;
import supershop4.dto.ProductDTO;
import supershop4.model.Product;

@Service
public class ProductServiceImpl implements IProductService {
	
	@Resource
	private IProductDao productDao;

	@Override
	public List<Product> findAll(ProductDTO dto) {
		return productDao.findAll(dto);
	}

	@Override
	public Object getCount(ProductDTO dto) {
		return productDao.getCount(dto);
	}

	@Override
	public int addOrEdit(Product p) {
		if(p.getId()==null) {
			return productDao.add(p);//添加
		}else {
			return productDao.edit(p);//修改
		}
	}

	@Override
	public int putOn(int id, String isPutOnSale) {
		return productDao.putOn(id, isPutOnSale);
	}

	@Override
	public int recommend(int id, String isToday) {
		return productDao.recommend(id, isToday);
	}

	@Override
	public int updateUrl(int id, String url) {
		return productDao.updateUrl(id, url);
	}

}
